import Vue from "vue";
import Vuex from "vuex";
import createPersistedState from "vuex-persistedstate";
Vue.use(Vuex);

export default new Vuex.Store({
  state: {
    token: "",
    username: "",
    userid: "",
    phone: "",
    role: "",
    menuList: [],
    tableHeight: "",
  },
  getters: {},
  mutations: {
    UPDATETOKEN(state, value) {
      state.token = value;
    },
    UPDATEUSERNAME(state, name) {
      state.username = name;
    },
    SETROLE(state, value) {
      state.role = value;
    },
    SETUSERID(state, value) {
      state.userid = value;
    },
    SETPHONE(state, value) {
      state.phone = value;
    },
    SETTABLEHEIGHT(state, value) {
      state.tableHeight = value;
    },
    SETMENULIST(state, value) {
      state.menuList = value;
    },
    RESVUEX(state, value) {
      state.token = "";
      state.username = "";
      state.menuList = [];
    },
  },
  actions: {},
  modules: {},
  // 配置为 vuex 的插件
  plugins: [createPersistedState()],
});
